#pragma once
#ifndef _ASIO_ASYNC_CONNECTOR_H_
#define _ASIO_ASYNC_CONNECTOR_H_
#include "Netbase.h"
#include <boost\asio.hpp>
#include <boost\bind.hpp>
#include <boost\thread.hpp>
using namespace boost;
using namespace boost::asio;

namespace XGC
{
	namespace net
	{
		class asio_NetworkHandler;
		typedef shared_ptr< asio_NetworkHandler > asio_NetworkHandlerPtr;

		class asio_AsyncConnector
		{
		public:
			asio_AsyncConnector( io_service &service );
			~asio_AsyncConnector(void);

			bool Connect( const char* pszAddress, short port, IMessageQueue* pMessageQueue, _uint32 nTimeout = 0 );

		protected:
			void handle_connect( asio_NetworkHandlerPtr pHandler, IMessageQueue* pMessageQueue, const system::error_code& error );

		private:
			io_service		&service_;
		};
	};
};

#endif //_ASIO_ASYNC_CONNECTOR_H_